const path = require('path')
const glob = require('glob')

const sidebar = ['/']
// 动态的读取components文件夹下的组件
const readFolder = async (path, list) => {
    const files = glob.sync(`${path}/**/**.md`)
    for (const file of files) {
        const l = file.split(/[./\\]/)
        let name = l[1]
        for (let i = 2; i < l.length - 1; i++) {
            name = name + '/' + l[i]
        }
        list.push(name)
    }
}
readFolder('docs/componentsDos', sidebar)

module.exports = {
    base: '/doc/',
    title: 'Hello VuePress',
    description: 'Just playing around',
    themeConfig: {
        sidebar
    },
    configureWebpack: {
        resolve: {
            alias: {
                // 配置图片资源路径别名
                '@img': path.resolve(__dirname, 'public/assets/images'),
                // 别的资源路径别名
                '@': path.resolve(__dirname, 'public')
            }
        }
    }
}
